
export interface IStorage {
    loadString(key: string): string | undefined;
    saveString(key: string, value: string): boolean;
  
    loadObject(key: string): object | undefined;

    saveObject(key: string, value: object): boolean;
  
    has(key: string): boolean;
    delete(key: string): string | object;
    clear(): boolean;
    size(): number;
  }
  
  
  export abstract class AbstractStorage implements IStorage {
    protected namespace: string;
    constructor(namespace: string) {
      this.namespace = namespace + ':';
    }
  
    abstract getString(key: string): string | undefined;
    abstract setString(key: string, value: string): boolean;
    abstract getObject(key: string): object | undefined;
    abstract setObject(key: string, value: object): boolean;
    abstract remove(key:string): string | object | undefined;
    abstract contain(key: string): boolean;
    abstract empty(): boolean;
    abstract count(): number;
  
  
    loadString(key: string): string | undefined {
      return this.getString(this.namespace + key);
    }
  
    saveString(key: string, value: string): boolean {
      return this.setString(this.namespace + key, value);
    }
  
    loadObject(key: string): object {
      return this.getObject(this.namespace + key); 
    }
  
    saveObject(key: string, value: object): boolean {
      return this.setObject(this.namespace + key, value);
    }
  
    delete(key: string): string | object | undefined {
      return this.remove(this.namespace + key);
    }

    has(key: string): boolean {
      return this.contain(key);
    }


    clear(): boolean {
      return this.empty();
    }
  
    size(): number {
      return this.count();
    }
  }
